package com.example.administrator.basedemos.activity;

import android.content.Context;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.view.LayoutInflaterCompat;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;

import com.example.administrator.basedemos.R;
import com.example.administrator.basedemos.typeface.ZhjFont;
import com.mikepenz.iconics.IconicsDrawable;
import com.mikepenz.iconics.context.IconicsContextWrapper;
import com.mikepenz.iconics.context.IconicsLayoutInflater2;
import com.mikepenz.ionicons_typeface_library.Ionicons;


/**
 * 创建者     ZCL
 * 创建时间   2018/3/29 17:01
 * 描述	      ${TODO}
 * <p>
 * 更新者     $Author$
 * 更新时间   $Date$
 * 更新描述   ${TODO}
 */

public  class IconicsActivity extends AppCompatActivity {

    private ImageView mImageView;
    private ImageView mImageView2;

    @Override
        protected void onCreate(Bundle savedInstanceState) {
        LayoutInflaterCompat.setFactory2(getLayoutInflater(), new IconicsLayoutInflater2(getDelegate()));
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_iconics);
            initView();
            initData();
            initListener();
        }

        private void initView() {
            mImageView = (ImageView) this.findViewById(R.id.imageView);
            mImageView2 = (ImageView) this.findViewById(R.id.imageView2);

        }

        private void initData() {
            IconicsDrawable drawableMe = new IconicsDrawable(this)
                    .icon(ZhjFont.Icon.ion_videocamera)
                    .color(Color.RED)
                    .sizeDp(100);

            IconicsDrawable drawable = new IconicsDrawable(this)
                    .icon(Ionicons.Icon.ion_heart)
                    .color(Color.RED)
                    .sizeDp(100);
            //使用自定的font图标
            mImageView.setImageDrawable(drawable);
            mImageView2.setImageDrawable(drawableMe);

        }

        private void initListener() {

        }

    /**
     * 不宠写这个直接使用imageview会报错
     * @param newBase
     */
    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(IconicsContextWrapper.wrap(newBase));
    }
}
